package com.xiaoyg;

import org.apache.catalina.User;

import java.util.PriorityQueue;
import java.util.Stack;

public class Math {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();

        stack.push(1);
        stack.push(2);
        stack.push(3);


        Integer peek = stack.peek();
        System.out.println(peek);

        stack.pop();
        System.out.println(stack.peek());
        stack.pop();
        System.out.println(stack.peek());



    }








    public static String palindrome(String s, int left,int right){
        while(left>= 0 && right < s.length() && s.charAt(left) == s.charAt(right)){
            left --;
            right ++;
        }
        return s.substring(left+1, right);
    }

    public static String longestPalindrome(String s){
        String result = "";
        for (int i = 0; i < s.length();i++){
            String s1 = palindrome(s,i,i);
            String s2 = palindrome(s,i,i+1);
            result = result.length() > s1.length() ? result : s1;
            result = result.length() > s2.length() ? result : s2;
        }
        return result;
    }

    public static boolean isPalindrome(String s) {
        int left = 0;
        int right = s.length() - 1;

        while(left < right){
            if(s.charAt(left) != s.charAt(right)){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}